package com.dews.web.controller.information;

import com.dews.common.annotation.Log;
import com.dews.common.core.controller.BaseController;
import com.dews.common.core.domain.BaseResponse;
import com.dews.common.core.page.TableDataInfo;
import com.dews.common.enums.BusinessType;
import com.dews.common.utils.poi.ExcelUtil;
import com.dews.common.utils.valid.AddGroup;
import com.dews.common.utils.valid.UpdateGroup;
import com.dews.information.domain.dto.SubjectCourseDTO;
import com.dews.information.domain.dto.SubjectCourseQueryDTO;
import com.dews.information.domain.vo.SubjectCourseVo;
import com.dews.information.service.ISubjectCourseService;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * 专业课程管理Controller
 * 
 * @author qingfeng
 * @date 2024-12-08
 */
@RestController
@Validated
@RequestMapping("/information/subjectCourse")
public class SubjectCourseController extends BaseController {

    private ISubjectCourseService subjectCourseService;

    @Autowired
    public SubjectCourseController(ISubjectCourseService subjectCourseService) {
        this.subjectCourseService = subjectCourseService;
    }

    /**
     * 查询专业课程管理列表
     */
    @PreAuthorize("@ss.hasPermi('information:subjectCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(SubjectCourseQueryDTO subjectCourseQueryDTO) {
        clearPage();
        return subjectCourseService.selectSubjectCourseList(subjectCourseQueryDTO);
    }

    @PreAuthorize("@ss.hasPermi('information:subjectCourse:list')")
    @GetMapping("/manageList")
    public TableDataInfo manageList(SubjectCourseQueryDTO subjectCourseQueryDTO) {
        clearPage();
        return subjectCourseService.selectSubjectCourseList(subjectCourseQueryDTO);
    }

    /**
     * 导出专业课程管理列表
     */
    @PreAuthorize("@ss.hasPermi('information:subjectCourse:export')")
    @Log(title = "专业课程管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SubjectCourseVo subjectCourseVo) {
        List<SubjectCourseVo> list = Collections.emptyList();
        ExcelUtil<SubjectCourseVo> util = new ExcelUtil<SubjectCourseVo>(SubjectCourseVo.class);
        util.exportExcel(response, list, "专业课程管理数据");
    }

    /**
     * 获取专业课程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('information:subjectCourse:query')")
    @GetMapping(value = "/{id}")
    public BaseResponse getInfo(@PathVariable("id") Integer id) {
        return success(subjectCourseService.selectSubjectCourseById(id));
    }

    /**
     * 新增专业课程管理
     */
    @PreAuthorize("@ss.hasPermi('information:subjectCourse:add')")
    @Log(title = "专业课程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResponse add(@RequestBody @Validated(AddGroup.class) SubjectCourseDTO subjectCourseDTO) {
        return toAjax(subjectCourseService.insertSubjectCourse(subjectCourseDTO));
    }

    /**
     * 修改专业课程管理
     */
    @PreAuthorize("@ss.hasPermi('information:subjectCourse:edit')")
    @Log(title = "专业课程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResponse edit(@RequestBody @Validated(UpdateGroup.class) SubjectCourseDTO subjectCourseDTO) {
        return toAjax(subjectCourseService.updateSubjectCourse(subjectCourseDTO));
    }

    /**
     * 删除专业课程管理
     */
    @PreAuthorize("@ss.hasPermi('information:subjectCourse:remove')")
    @Log(title = "专业课程管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResponse remove(@PathVariable List<Integer> ids) {
        return toAjax(subjectCourseService.deleteSubjectCourseByIds(ids));
    }

    @ApiOperation(value = "查询封装讲师list")
    @GetMapping("/getTeacherList")
    public BaseResponse getTeacherList() {
        return success(subjectCourseService.getTeacherList());
    }

    @ApiOperation(value = "查询教师教学的专业课程信息列表")
    @PreAuthorize("@ss.hasPermi('information:getTeacherCourseList:list')")
    @GetMapping("/getTeacherCourseList")
    public BaseResponse getTeacherCourseList() {
        return success(subjectCourseService.getTeacherCourseList());
    }

}
